/**
 * @description: 路由
 * @author: nowThen
 */

import Vue from 'vue';
import Router from 'vue-router';

const Hello = () =>
    import ( /* webpackChunkName: "apply" */ '@/views/hello');
const Demo = () =>
    import ( /* webpackChunkName: "demo" */ '@/views/demo');
const VueView = () =>
    import ( /* webpackChunkName: "demo" */ '@/views/vueView');
const Error = () =>
    import ( /* webpackChunkName: "error" */ '@/views/error');
const Details = () =>
    import ( /* webpackChunkName: "error" */ '@/views/details');

Vue.use(Router);

const routes = [{
        path: '/',
        name: 'hello',
        component: Hello,
        meta: {
            title: '首页'
        },
        // children: [
        //     // 当 /user/:id 匹配成功，
        //     // UserHome 会被渲染在 User 的 <router-view> 中
        //     { path: 'Details/:id', component: Details },

        //     // ...其他子路由
        // ]
    },
    {
        path: '/demo',
        name: 'demo',
        component: Demo,
        meta: {
            title: '我的文章', // 标题
            requireAuth: false, // 登录权限
            keepAlive: false,
        },

    },
    {
        path: '/vueView',
        name: 'vueView',
        component: VueView,
        meta: {
            title: '市场'
        }
    },
    {
        path: '/error',
        name: 'error',
        component: Error,
        meta: {
            title: '404页'
        }
    },
    {
        path: '/Details/:id',
        name: 'Details',
        component: Details,
        meta: {
            title: '详情页'
        }
    },
    {
        path: '*',
        redirect: 'error',
    },
];

const router = new Router({
    mode: 'history',
    // mode: 'hash',
    routes
})

export default router;